package net.fltx.Ax;

import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.FaultAction;

public class AxCell {
	/**
	 * 不可通行
	 */
	public static final int IMPASSABLE =-1;
	/**
	 * 可通行
	 */
	public static final int PASSABLE =0;
	
	/**
	 * 起点
	 */
	public static final int START =1;
	
	/**
	 * 终点
	 */
	public static final int END =2;
	
	/**
	 * x坐标
	 */
	public int x;
	/**
	 * y坐标
	 */
	public int y;
	
	/**
	 * 与远点距离 步数
	 */
	public int step;
	
	/**
	 * 设置格子类型,可通行,不可通行,起点,终点
	 */
	public int type;
	/**
	 * 与终点距离
	 */
	public double distance;
	
	public int getX() {
		return x;
	}
	public AxCell setX(int x) {
		this.x = x;
		return this;
	}
	public int getY() {
		return y;
	}
	public AxCell setY(int y) {
		this.y = y;
		return this;
	}
	public int getStep() {
		return step;
	}
	public AxCell setStep(int step) {
		this.step = step;
		return this;
	}
	public int getType() {
		return type;
	}
	public AxCell setType(int type) {
		this.type = type;
		return this;
	}
	public double getDistance() {
		return distance;
	}
	public AxCell setDistance(double distance) {
		this.distance = distance;
		return this;
	}

	public AxCell setDistance(AxCell axCell) {
		this.distance = survey(this, axCell);
		return this;
	}
	
	public AxCell(int x, int y, int step, int type, double distance) {
		this.x = x;
		this.y = y;
		this.step = step;
		this.type = type;
		this.distance = distance;
	}
	@Override
	public String toString() {
		return "AxCell [x=" + x + ", y=" + y + ", step=" + step + ", type=" + type + ", distance=" + distance + "]";
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(distance);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + step;
		return result;
	}
//	@Override
//	public boolean equals(Object obj) {
//		if (this == obj)
//			return true;
//		if (obj == null)
//			return false;
//		if (getClass() != obj.getClass())
//			return false;
//		AxCell other = (AxCell) obj;
//		if (Double.doubleToLongBits(distance) != Double.doubleToLongBits(other.distance))
//			return false;
//		if (step != other.step)
//			return false;
//		return true;
//	}
	
	/**
	 * 测量,测量a点到b点的直线距离
	 * @param a
	 * @param b
	 * @return
	 */
	public static double survey(AxCell a,AxCell b){
		int w=a.x-b.x;
		int h=a.y-b.y;
		return Math.sqrt(w*w+h*h);
	}
}
